<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加员工</title>
   <link href="css/contract.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--header-->
<div class="top_box">
    <div id="" class="top">
        <div class="top_left">企业级视频直播解决方案</div>
        <div class="top_right"><a href="">关于我们&nbsp;&nbsp;</a>▏服务热线：400-048-2820</div>
        <div class="clearfix"></div>
    </div>

</div>
<div class="header_box">
    <div class="header">
        <div class="logo">
            <a href="#"><img src="images/logo.png"></a>

        </div>
        <ul class="tab_menu">

        </ul>
        <div class="clearfix"></div>
    </div>
</div>

<!--main-->
<div class="main">
    <div class="apply_box">
        <form  id="addForm" action="adminAdd" method="post">
            <ul class="form_ul">
                <li><label>登陆账号:</label><input type="text" name="account" id="account" value="" onblur="accountOnclick();" maxlength="20" placeholder="登陆账号"></li>
                <li><label>姓名:</label><input type="text" name="name" id="name" value="" placeholder="姓名" maxlength="10"></li>
                <li><label>密码:</label><input type="password" name="password" id="password"  placeholder="默认(P@ssword123)" maxlength="18"></li>
                <li><label>电子邮件:</label><input type="text" name="mail" id="mail" onblur="mailOnlick();" value="" onchange="telephoneOnchange()"  placeholder="电子邮件" maxlength="25"></li>
				<li><label>备注:</label><input type="text" name="comments" id="comments"  value=""  placeholder="备注" maxlength="100"></li>
					     <li class="submit" style="border: none"><input type="button" onclick="submitContract();"  style="cursor:pointer" value="提交"><input type="button" onclick="history.go(-1)" style="cursor:pointer;margin-left: 20px;" value="返回"></li>
            </ul>
        </form>
    </div>
</div>
<!--foot-->
<div class="footer_box">
    <div class="footer">
        <p>Copyright@2016&nbsp;ZoomCloud&nbsp;众标科技,&nbsp; All&nbsp; right&nbsp; reserved.&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.miit.gov.cn" style="color: #8b97b1; text-decoration: none !important">皖ICP备16019558号</a> </p>
    </div>
</div>
</body>
<script src="js/jquery-1.7.2.js"></script>
<script src="js/jquery.tips.js"></script>
<script type="text/javascript">

function accountOnclick(){
    var inp= document.getElementById("account");
    var reg = /^[A-Za-z0-9]+$/;
    var result= reg.test(inp.value);
    if(!result)
    {
 	   $("#account").tips({
				side : 1,
				msg : '只能输入字母和数字',
				bg : '#AE81FF',
				time : 3
			});
 	  return false;
    }
    var account = $("input[name='account']").val();
   $.ajax({
    	type: "POST",
		url: 'checkAccount',
    	data: {account :account },
    	dataType: "html",
		cache: false,
		success: function(data) {
			if(data==1){
				$("#account").tips({
					side : 1,
					msg : '账号已存在',
					bg : '#AE81FF',
					time : 5
				});
				$("#contractNo").focus();
				return false;
			}
		}
	}); 
   }
function mailOnlick() {
	var inp= document.getElementById("mail");
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var result = filter.test(inp.value);
	if (!result) {
		$("#mail").tips({
			side : 1,
			msg : '请输入正确的邮箱！',
			bg : '#AE81FF',
			time : 3
		});
		return false;
	}
}
function submitContract(){
			var account = $("input[name='account']").val();
			var name = $("input[name='name']").val();
			var mail = $("input[name='mail']").val();
			if (account == "") {
					$("#account").tips({
						side : 1,
						msg : '登陆账号不得为空',
						bg : '#AE81FF',
						time : 3
					});

					$("#account").focus();
					return false;
				}
				if (name == "") {
					$("#name").tips({
						side : 1,
						msg : '姓名不得为空',
						bg : '#AE81FF',
						time : 3
					});
					$("#name").focus();
					return false;
				}
				
				if (mail == "") {
					$("#mail").tips({
						side : 1,
						msg : '电子邮件不得为空',
						bg : '#AE81FF',
						time : 3
					});

					$("#mail").focus();
					return false;
				}
				    var reg = /^[A-Za-z0-9]+$/;
				    var result= reg.test(account);
				    if(!result)
				    {
				 	   $("#account").tips({
								side : 1,
								msg : '只能输入字母和数字',
								bg : '#AE81FF',
								time : 3
							});
				 	  return false;
				    }
				    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					var result = filter.test(mail);
					if (!result) {
						$("#mail").tips({
							side : 1,
							msg : '请输入正确的邮箱！',
							bg : '#AE81FF',
							time : 3
						});
						return false;
					}
					$.ajax({
				    	type: "POST",
						url: 'checkAccount',
				    	data: {account :account },
				    	dataType: "html",
						cache: false,
						success: function(data) {
							if(data==1){
								$("#account").tips({
									side : 1,
									msg : '账号已存在',
									bg : '#AE81FF',
									time : 5
								});
								$("#contractNo").focus();
								return false;
							}
								$("#addForm").submit();
								}
						});
				}
				
				</script>
</html>